home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / ResEdit / ResEdit 2.0b2 / Examples / PExamples / Source / ICON.LDEF.p next >
Encoding:
Text File  |  1990-04-02  |  1.8 KB  |  73 lines  |  [TEXT/MPS ]

  1. {
  2.  COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
  3.  All rights reserved
  4. }
  5. UNIT IconLDEF;
  6.  
  7. INTERFACE
  8.  
  9. Uses    MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
  10.             ResEd;
  11.  
  12. PROCEDURE DrawCell( Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
  13.                     lDataOffset, lDataLen: INTEGER; lh: ListHandle );
  14.  
  15. IMPLEMENTATION
  16.  
  17. PROCEDURE DrawIcon (lRect: Rect; theIcon: Handle);
  18.  
  19. BEGIN
  20. PlotIcon(lRect, theIcon);
  21. END;
  22.  
  23. { This is the custom drawProc for the list (which contains the resource ID's).  It
  24.     simply draws the icon in the given rect and frames a selection rect around it if
  25.     told to. 
  26.     NOTE:  This is used by both ICON and ICN# pickers. }
  27. PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
  28.                    lDataOffset, lDataLen: INTEGER; lh: ListHandle);
  29.  
  30. VAR
  31.     theIcon: Handle;
  32.     id: INTEGER;
  33.     
  34.     { This routine simply looks up in the list at the given cell, extracts the ID and
  35.         gets the resource called for.  Returns NIL if not found.  Note, this assumes
  36.         the resfile is set up correctly }
  37.     FUNCTION  IconFetch(lCell: point; lHandle: ListHandle): Handle ;
  38.     CONST IconSize = 128;
  39.  
  40.     VAR
  41.         len, saveResFile: INTEGER;
  42.         tempH:Handle;
  43.         
  44.     BEGIN
  45.     saveResFile := CurResFile;
  46.     UseResFile ( PickHandle(lHandle^^.refCon)^^.rNum);
  47.     IconFetch := NIL;
  48.     len:=2;
  49.     LGetCell(@id, len, lCell, lHandle);    { Get the ID from the list. }
  50.     IF len > 0 THEN
  51.         BEGIN    { Load the resource since we want to draw it. }
  52.         tempH := Get1Res(PickHandle(lHandle^^.refCon)^^.rType, id);
  53.         IF (SizeResource(tempH) < IconSize) THEN
  54.             IconFetch := NIL    { Bad resource. }
  55.         ELSE
  56.             IconFetch := tempH;
  57.         END;
  58.     UseResFile (saveResFile);
  59.     END;
  60.  
  61. BEGIN    { DrawCell }
  62. CASE  message OF
  63.     lDrawMsg, lHiliteMsg:
  64.         BEGIN
  65.         theIcon := IconFetch(lCell, lh);
  66.  
  67.         DrawLDEF (message, lSelect, lRect, theIcon, id, '', 32, 32, @DrawIcon, lh);
  68.         END;
  69.     END;
  70. END;
  71.  
  72. END.
  73.